package org.example.models;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 响应数据类
 */
@AllArgsConstructor
@Data
public class R<T> {
    private int code = 200;//响应码
    private String msg = "success";//响应信息
    private T data;//响应数据

    public static <T> R<T> success(T data){
        return new R(200,"success",data);
    }
    public static <T> R<T> success(){
        return new R(200,"success",null);
    }

    public static <T> R<T> success(int code){
        return new R(code,"success",null);
    }
    public static <T> R<T> success(String msg){
        return new R(200,msg,null);
    }
    public static <T> R<T> success(int code,String msg){
        return new R(code,msg,null);
    }
    public static <T> R<T> success(int code,String msg,T data){
        return new R(code,msg,data);
    }
    public static <T> R<T> error(String msg){
        return new R(500,msg,null);
    }

    public static <T> R<T> error(int code,String msg){
        return new R(code,msg,null);
    }
}
